{% extends 'base.html' %}


{% block content %}

<div class="container mt-3">
    <!-- 面包屑 -->
    <div class="row">
        <div class="col-12">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{% url 'expense' %}">首页</a></li>
                    <li class="breadcrumb-item"><a href="{% url 'expense' %}">支出</a></li>
                    <li class="breadcrumb-item active" aria-current="page">添加支出</li>
                </ol>
            </nav>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-body">
                    <form action="{% url 'add-expense' %}" method="post">
                        {% csrf_token %}
                        {% include 'partials/messages.html' %}
                        <div class="form-group">
                            <label for="amountField" class="form-label">金额</label>
                            <input type="number" value="{{ values.amount }}" class="form-control" name="amount"
                                id="amountField">
                        </div>
                        <div class="form-group">
                            <label for="categoryField" class="form-label">类型</label>
                            <select class="form-control" name="category" id="categoryField">
                                <option value="" name="category">请选择...</option>
                                {% for c in categories %}
                                    {% if c.name == values.category %}
                                    <option value="{{ c.name }}" name="category" selected>{{ c.name }}</option>
                                    {%else%}
                                    <option value="{{ c.name }}" name="category">{{ c.name }}</option>
                                    {%endif%}
                                {% endfor %}
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="descriptionField" class="form-label">描述</label>
                            <input type="text" value="{{ values.description }}" class="form-control" name="description"
                                id="descriptionField">
                        </div>
                        <div class="form-group">
                            <label for="dateField" class="form-label">日期</label>
                            <input type="date" class="form-control" name="date" id="dateField"
                                value="{%if values.date%}{{values.date}}{%else%}{% now 'Y-m-d' %}{%endif%}">
                        </div>
                        <input type="submit" value="添加" class="btn btn-primary mt-2">
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


{% endblock %}